package models

import (
	"gorm.io/gorm"
	"servers/basic/config"
	"time"
)

type Cleaner struct {
	Id            uint           `gorm:"column:id;type:bigint UNSIGNED;primaryKey;not null;" json:"id"`
	Realname      string         `gorm:"column:realname;type:varchar(255);comment:真实姓名;not null;" json:"realname"`                                          // 真实姓名
	OrderType     uint           `gorm:"column:order_type;type:int UNSIGNED;comment:订单模式：1：实时单 2：预约单;not null;default:0;" json:"order_type"`                // 订单模式：1：实时单 2：预约单
	CleanerStatus uint           `gorm:"column:cleaner_status;type:int UNSIGNED;comment:保洁师状态：1：空闲中 2：已接单 3：已拒单;not null;default:0;" json:"cleaner_status"` // 保洁师状态：1：空闲中 2：已接单 3：已拒单
	CreatedAt     time.Time      `gorm:"column:created_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"created_at"`
	UpdatedAt     time.Time      `gorm:"column:updated_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"updated_at"`
	DeletedAt     gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);default:NULL;" json:"deleted_at"`
}

func (c *Cleaner) TableName() string {
	return "cleaner"
}
func (c *Cleaner) UpdateOrderType() error {
	return config.DB.Where("id = ?", c.Id).Updates(&c).Error
}
